package com.limao.DBProvider;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.limao.DBDataClass.CrowdVRUserRmbClass;
import com.limao.DbConnection.DbConnectionManager;

public class CrowdVRUserRmbProvider {

	private static CrowdVRUserRmbProvider instance;

	public static CrowdVRUserRmbProvider getInstance() {
		if(instance==null) instance=new CrowdVRUserRmbProvider();
		return instance;
	}
	
  
	private CrowdVRUserRmbProvider() {

	}

	private CrowdVRUserRmbClass encapOrderData(ResultSet rs) throws Exception{
		
		CrowdVRUserRmbClass orderData = new CrowdVRUserRmbClass();

		orderData.userid=rs.getString("userid");
		
		orderData.vrprinciplelrmb=rs.getString("vrprinciplelrmb");
		orderData.vrcashgiftrmb1=rs.getString("vrcashgiftrmb1");
		orderData.vrcashgiftrmb2=rs.getString("vrcashgiftrmb2");
		
		orderData.vrcashgiftrmb3=rs.getString("vrcashgiftrmb3");
		orderData.netvalueRmb=rs.getString("netvalueRmb");
		
		orderData.vrnowrmb=rs.getString("vrnowrmb");
		orderData.vrnowcashgiftrmb1=rs.getString("vrnowcashgiftrmb1");
		orderData.vrnowcashgiftrmb2=rs.getString("vrnowcashgiftrmb2");
		
		orderData.vrpreorderrmb=rs.getString("vrpreorderrmb");
		orderData.vailtime=rs.getString("vailtime");
		
		

		
	
		return orderData;
	}
			
	
	
	public CrowdVRUserRmbClass Load_CrowdVRUserRmb_Byuserid(int userid)
	{
		CrowdVRUserRmbClass tmp=null;
		Connection con = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
			try {
				con = DbConnectionManager.getConnection();
				pstmt = con.prepareStatement("select * from vr_user_rmb where userid=?");
				pstmt.setInt(1, userid);
				rs=pstmt.executeQuery();
				if(rs.next())
				{
					tmp=encapOrderData(rs);
				}

			} catch (Exception e) {
				e.printStackTrace();
				tmp=null;
			} finally {
				DbConnectionManager.closeConnection(rs, pstmt, con);
			}
			return tmp;
	}
	
	
	
}
